package com.lyf.boot.modules.index.controller;

import com.lyf.boot.core.model.R;
import com.lyf.boot.modules.index.entity.MenuTreeVo;
import com.lyf.boot.modules.index.entity.ProfileVo;
import com.lyf.boot.modules.index.service.IProfileService;
import com.lyf.boot.modules.system.service.ISysPermService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 个人信息接口
 * @author Luyufan
 * @date 2023/7/6 10:52
 */
@RestController
@RequestMapping("/profile")
@RequiredArgsConstructor
public class ProfileController {

    private final ISysPermService sysPermService;

    private final IProfileService profileService;

    /**
     * 查询个人信息
     * @return
     */
    @PostMapping("/info")
    public R<ProfileVo> getProfile(){
        return R.ok(profileService.getProfile());
    }

    /**
     * 获取权限编码
     * @return
     */
    @PostMapping("/getPermCode")
    public R<List<String>> getPermissionCode(){
        return R.ok(sysPermService.getUserPermCodes());
    }

    /**
     * 获取权限
     * @return
     */
    @PostMapping("/getMenuList")
    public R<List<MenuTreeVo>> getMenuList(){
        return R.ok(sysPermService.getUserPerm());
    }
}
